package lab02.test17;

/**
 * Created by tianxiadiyishuai on 2017/10/26.
 */
public class Test {
    //定义一个10个元素组成的一维数组
    //输出该数组中的最大值、最小值、所有元素总和
    //最大值和最小值在该数组中的位置
    //ctrl+d：复制一行
    //ctrl+x:删除一行
    public static void main(String[] args) {
        int[] numbers = new int[10];//整形数组
        numbers[0] = 12;
        numbers[1] = 9;
        numbers[2] = 26;
        numbers[3] = 54;
        numbers[4] = 95;
        numbers[5] = 919;
        numbers[6] = 993;
        numbers[7] = 994;
        numbers[8] = 995;
        numbers[9] = 996;
        //打印数组中所有元素
        //System.out.println(numbers[0]);
        //System.out.println(numbers[1]);
        //System.out.println(numbers[2]);
        //System.out.println(numbers[3]);
        // System.out.println(numbers[4]);
        //System.out.println(numbers[5]);
        // System.out.println(numbers[6]);
        // System.out.println(numbers[7]);
        // System.out.println(numbers[8]);
        //System.out.println(numbers[9]);
        //下标
        int index;
        for (index = 0; index < numbers.length; index++) {
            System.out.println(numbers[index]);
        }
        int sum = 0;
        int max=numbers[0];
        int min=numbers[0];
        int i;
        for (i = 0; i < numbers.length; i++) {
            sum += numbers[i];
        if(max<numbers[i]){
            max=numbers[i];
        }
        else if(min>numbers[i]){
            min=numbers[i];
        }
        }
        System.out.println("总和是:" + sum);
        System.out.println("最大值："+max);
        System.out.println("最小值："+min);
    }
}
